package huawei;

public class candyDivide {


    public static void main(String[] args) {

        candyDivide candyDivide = new candyDivide();
        int i = candyDivide.minTimes(15, 0);
        System.out.println(i);
    }

    public int minTimes (int candyCount, int count) {
        if (candyCount == 1) {
            return count;
        }
        int t1 = Integer.MAX_VALUE, t2 = Integer.MAX_VALUE, t3 = Integer.MAX_VALUE;
        if (candyCount % 2 == 1) {
            t1 = minTimes((candyCount + 1) / 2, count + 2);
            t2 = minTimes((candyCount - 1) / 2, count + 2 );
        } else {
            t3 = minTimes(candyCount / 2, count + 1);
        }
        return Math.min(Math.min(t1, t2), t3);
    }
}
